package coordinators;

import java.util.ArrayList;
import queries.Insert;
import windows.ManageInsumosCreate;
import windows.ManageInsumosDelete;
import windows.ManageInsumosModify;
import windows.ManageInsumosShow;
import windows.RelationInsumoAmoutn;


/**
 * @author KRISTHI@N
 *
 */
public class CoordinatorInsumos
{
	ManageInsumosCreate manageInsumosCreate;
	ManageInsumosModify manageInsumosModify;
	ManageInsumosDelete manageInsumosDelete;
	ManageInsumosShow   manageInsumosShow;
	
	public CoordinatorInsumos(ManageInsumosCreate manageInsumosCreate)
	{
		this.manageInsumosCreate = manageInsumosCreate;
	}
	
	public CoordinatorInsumos(ManageInsumosModify manageInsumosModify) 
	{
		this.manageInsumosModify = manageInsumosModify;
	}

	public CoordinatorInsumos(ManageInsumosDelete manageInsumosDelete)
	{
		this.manageInsumosDelete = manageInsumosDelete;
	}
	
	public CoordinatorInsumos(ManageInsumosShow manageInsumosShow)
	{
		this.manageInsumosShow = manageInsumosShow;
	}

	public void buyInsumos(String sNameList, ArrayList<RelationInsumoAmoutn> listInsumos)
	{
		Insert insert;
		insert= new Insert();
		String sQuerie;
		sQuerie="Insert into pedido_insumos values(null,CURDATE(),'"+sNameList+"')";
		insert.insertData(sQuerie);
		int code,codeOrder = 0;
		for(RelationInsumoAmoutn relation: listInsumos)
		{
			sQuerie="Select Codigo_insumos from insumos where nombre='"+relation.getSInsumo()+"'";
			code = insert.insertInsumos(sQuerie);
			sQuerie="Select codigo from pedido_insumos where NombreLista='"+sNameList+"'";
			codeOrder = insert.insertInsumos(sQuerie);
			sQuerie="Insert into detalle_pedido_insumos values("+codeOrder+","+code+","+relation.getNAmount()+")";
			insert.insertData(sQuerie);
		}
		manageInsumosCreate.txtCodInsumo.setText(""+codeOrder);
	}
	
}
